<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<title>(ST)商城专业化管理系统</title>
<meta name="keywords" content="soulteam" />
<meta name="description" content="soulteam" />
<link rel="shortcut icon" href="images/favicon.ico" />
<link href="css/layout.css" rel="stylesheet" type="text/css">
<link href="css/login.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/js.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script src="assets/layer/layer.js" type="text/javascript"></script>
<link rel="icon" href="#" />
</head>

<body class="login-bg">
	<!--登录-->
	<div class="main">
		<div class="login-dom">
			<div class="logo text-center"
				style="position: absolute; right: 350px; top: 140px;">
				<img src="images/logo2.png" width="180" height="180">
			</div>
			<!--注册-->
			<div style="margin-left: -192px;">
				<div style="margin-top: 17px;"></div>
				<div class="text-big text-center logo-color">同一个账号，连接一切</div>
				<div class=" text-center margin-small-top logo-color text-small">控制台
					| 云平台 | 论坛 | 云市场</div>
				<form class="register-form" method="post" autocomplete="off">
					<div class="reg-wrap border">
						<div class="name reg user">
							<span class='tag'>用户名</span> <input type="text"
								placeholder="请输入用户名" id="username" name="username"
								onblur="usernameOnblur()"> <span class='wr uu'></span>
						</div>
						<div class="pwd reg">
							<span class='tag pw'>密码</span> <input type="password"
								placeholder="输入密码" id="password" name="password"
								onblur="passwordOnblur()"> <span class='wr pwwr'
								id="ccc"></span>
						</div>
						<div class="pwd reg">
							<span class='tag repw'>再次确认</span> <input type="password"
								placeholder="请确认密码" id="password1" name="password1"
								onblur="password1Onblur()"> <span class='wr repwwr'></span>
						</div>
						<div class="name reg">
							<span class='tag sex'>性别</span> <input type="text"
								placeholder="请输入性别" id="sex" name="sex" onblur="sexOnblur()">
							<span class='wr sexwr'></span>
						</div>
						<div class="name reg">
							<span class='tag age'>年龄</span> <input type="text"
								placeholder="请输入年龄" id="age" name="age" onblur="ageOnblur()">
							<span class='wr agewr'></span>
						</div>
						<div class="name reg">
							<span class='tag phone'>移动电话</span> <input type="text"
								placeholder="请输入移动电话" id="phone" name="phone"
								onblur="phoneOnblur()"> <span class='wr phonewr'></span>
						</div>
						<div class="name reg">
							<span class='tag email'>电子邮箱</span> <input type="text"
								placeholder="请输入电子邮箱" id="email" name="email"
								onblur="emailOnblur()"> <span class='wr emailwr'></span>
						</div>
						<div class="name reg">
							<span class='tag qq'>qq</span> <input type="text"
								placeholder="请输入qq" id="qq" name="qq" onblur="qqOnblur()">
							<span class='wr qqwr'></span>
						</div>
					</div>
					<input type="hidden" name="formhash" value="5abb5d21" />
					<div class="margin-large-top padding-big-top regist">
						<div>
							<span class="btn text-big" value="立即注册" id="zhuce">&emsp;&emsp;&emsp;&emsp;
								&emsp;&emsp;&emsp;&nbsp;&nbsp;立即注册</span>
						</div>
					</div>
					<!-- <div class="reg-btn text-center text-big logo-color" type="submit">立即注册</div> -->
				</form>
			</div>
			<div class="forget ff">
				<a href="repassword.html" class="forget-pwd text-small fl">忘记登录密码？</a>
				<a href="login.html" class="forget-new text-small fr"
					id="forger-login">已有账号，立即登录</a>
			</div>
		</div>
		<div class="footer text-center  text-small">
			Copyright 2019 CGB1908 SOULTEAM研发 <a href="#" target="_blank"></a> <span
				class="margin-left margin-right"></span>
		</div>
	</div>

	<div class="popupDom">
		<div class="popup  text-default"></div>
	</div>
	</div>
	<script type="text/javascript" src="js/Validform_v5.3.2_min.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#zhuce").click(doRegist);
		})

		function sexOnblur() {
			var sex = $("#sex").val();
			if (sex == "") {
				$(".sexwr").html("请输入男or女");
				return;
			} else if (sex == "男") {
				$(".sexwr").html("");
				return;
			} else if (sex == "女") {
				$(".sexwr").html("");
				return;
			} else {
				$(".sexwr").html("请输入男or女");
				return;
			}

		}

		function emailOnblur() {
			var email = $("#email").val();
			var Expression = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
			if (!Expression.test(email)) {
				$(".emailwr").html("邮箱格式不对")
				return;
			} else {
				$(".emailwr").html("")
				return;
			}
		}

		function ageOnblur() {
			var age = $("#age").val();
			var reg = /^(?:[1-9][0-9]?|1[01][0-9]|120)$/;
			if (!reg.test(age)) {
				$(".agewr").html("亲,请输入正确年龄");
				return;
			} else {
				$(".agewr").html("");
				return;
			}
		}

		function usernameOnblur() {
			//debugger;
			var username = $("#username").val();
			//var user = /^[a-zA-Z]\w{3,15}$/;
			/*  if (!user.test(username)) {
				$(".uu").html("用户格式不对")
				return;
			}
			$(".uu").html("")  */

			if (username == "") {
				$(".uu").html("用户名不能为空!")
				return;
			}
			
			$(".uu").html("");
			
			$.post("/query", {
				"username" : username
			}, function(result) {
				if (result.data == 1) {
					$(".uu").html("用户名已存在");
					return;
					/* layer.alert("用户名已存在", {
						title : '提示框',
						icon : 2,
					}); */
				} else {
					$(".uu").html("");
				}
			});
		}

		function passwordOnblur() {
			var password = $("#password").val();
			//var pwd = /^[1-9][0-9]{4,9}$/gim;
			///^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{6,}$/;	
			/* if (!pwd.test(password)) {
				$("#ccc").html("密码格式不对")
			} else {
				$("#ccc").html("")
			} */
			if (password == "") {
				$("#ccc").html("密码不能为空");
				return;
			} else {
				$("#ccc").html("");
				return;
			}

		}

		function phoneOnblur() {
			var phone = $("#phone").val();
			var phoneT = /^[1-9][0-9]{10}$/gim;
			if (!phoneT.test(phone)) {
				$(".phonewr").html("手机格式不对")
				return;
			} else {
				$(".phonewr").html("")
				return;
			}
		}

		function password1Onblur() {
			var password = $("#password").val();
			var password1 = $("#password1").val();
			if (password1 != password) {
				$(".repwwr").html("两次密码不一致")
				return;
			} else {
				$(".repwwr").html("")
				return;
			}
		}

		function qqOnblur() {
			var qq = $("#qq").val();
			var reg = /^[1-9][0-9]{4,9}$/gim;
			if (!reg.test(qq)) {
				$(".qqwr").html("qq格式不对")
				return;
			} else {
				$(".qqwr").html("")
				return;
			}
		}

		function doRegist() {
			var username = $("#username").val();
			var password = $("#password").val();
			var sex = $("#sex").val();
			var age = $("#age").val();
			var phone = $("#phone").val();
			var email = $("#email").val();
			var qq = $("#qq").val();
			/* alert(username);
			alert(password);
			alert(sex);
			alert(age);
			alert(phone);
			alert(email);
			alert(qq); */
			if (username == "" || password =="" || sex =="" || age =="" || phone ==""
				|| email =="" || qq =="") {
				layer.alert("请输入有效信息", {
					title : '提示框',
					icon : 2,
				});
				return;
			}

			var parms = {
				"username" : username,
				"password" : password,
				"gender" : sex,
				"permission" : age,
				"phone" : phone,
				"email" : email,
				"qq" : qq
			}
			var url = "/regist";
			$.post(url, parms, function(result) {
				if (result.state == 1) {
					location.href = "login";
				}
			});
		}
	</script>
	<script type="text/javascript">
		/*动画（注册）*/
		$(document).ready(function(e) {
			var register = [];

			/*仿刷新：检测是否存在cookie*/
			$mobile = '';
			$time = 0;
			if (register) {
				$time = parseInt(new Date().getTime() / 1000 - register.time);
				$("input[name=mobile]").attr('value', register.mobile);
				_status($time);
			}
			$("input[name=mobile]").focus();

			$('form[name=register]').Validform({
				ajaxPost : true,
				tiptype : function(msg) {
					if (msg)
						popup('' + msg + '');
				},
				callback : function(ret) {
					popup('' + ret.info + '');
					if (ret.status == 1) {
						if (ret.uc_user_synlogin) {
							$("body").append(ret.uc_user_synlogin);
						}
						window.location.href = ret.url;
					}
				}
			})
		});

		/*发送验证码*/
		$("#send").click(function() {
			var obj = $("input[name=mobile]");
			if ($(this).attr('disabled')) {
				return false;
			}
			if (obj.val() == "") {
				popup("请输入手机号码")
				obj.focus();
				return false;
			}
			$.post("http://account.haidao.la/index.php?c=Index&a=vcode", {
				mobile : obj.val(),
			}, function(ret) {
				if (ret.status == 0) {
					popup(ret.info);
					return false;
				}
				$("input[name=vcode]").removeAttr('disabled');
				_status(60);
			}, 'json');
		});

		function _status(count) {
			var $send_sms = $("#send");
			var count = count;
			$send_sms.attr('disabled', 'disabled');
			var resend = setInterval(function() {
				count--;
				if (count > 0) {
					$('#send').html(count + '秒后重试');
					$("input[name='vcode']").removeAttr('disabled');
					$.cookie("register_vcode", count, {
						path : '/',
						expires : (1 / 86400) * count
					});

				} else {
					clearInterval(resend);
					$send_sms.html("重获验证码").removeAttr('disabled');
					$.cookie("register_vcode", null);
				}
			}, 1000);
		}
	</script>
</body>

</html>